package com.example.demo.controller;

import com.example.demo.service.Animal;
import com.example.demo.utils.BeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
@Slf4j
public class ContextDemo {

    @Autowired
    Animal dog;

    @RequestMapping("/bean")
    public void print() {
        dog.print();
        Animal dog2 = (Animal) BeanUtil.getBean("dog2");
        dog2.print();
    }
}
